package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.common.PageBean;
import com.itheima.dtos.PageOperateLogDto;
import com.itheima.mapper.OperationLogMapper;
import com.itheima.pojo.OperateLog;
import com.itheima.service.OperateLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OperateLogServiceImpl  implements OperateLogService {

    @Autowired
    OperationLogMapper operationLogMapper;


    /**
     * 分页查询
     * @param pageOperateLogDto 页码数, 每页条数
     * @return 查到的数据
     */
    @Override
    public PageBean<OperateLog> queryPage(PageOperateLogDto pageOperateLogDto) {
        PageHelper.startPage(pageOperateLogDto.getPage(), pageOperateLogDto.getPageSize());

        List<OperateLog> list = operationLogMapper.queryPage(pageOperateLogDto);
        Page<OperateLog> p = (Page<OperateLog>) list;
        return new PageBean<>(p.getTotal(), p.getResult());

    }
}
